package mythread;

public class MyThread extends Thread {

	private int count=5;

	/**
	 * 添加了synchronized关键字
	 * synchronized可以在任意对象及方法上加锁，而加锁的这段代码称为"互斥区"或"临界区"
	 */
	@Override
	synchronized public void run() {
		super.run();
			count--;
			System.out.println("由 "+this.currentThread().getName()+" 计算得count="+count);
	}
}
